package com.smallcc.util;

import com.smallcc.enums.CodeEnum;

/**
 * @author 晓风过境
 * @TODO
 * @date 2018/4/1 15:38
 * @day 01
 * @return $text$
 * @title ${CLASS_NAME}
 * @project_name sell
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
